package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.RoutingLine;
import com.ruoyi.system.service.IRoutingLineService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 巡检线路1Controller
 * 
 * @author ruoyi
 * @date 2023-11-29
 */
@Controller
@RequestMapping("/system/line")
public class RoutingLineController extends BaseController
{
    private String prefix = "system/line";

    @Autowired
    private IRoutingLineService routingLineService;

    @RequiresPermissions("system:line:view")
    @GetMapping()
    public String line()
    {
        return prefix + "/line";
    }

    /**
     * 查询巡检线路1列表
     */
    @RequiresPermissions("system:line:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RoutingLine routingLine)
    {
        startPage();
        List<RoutingLine> list = routingLineService.selectRoutingLineList(routingLine);
        return getDataTable(list);
    }

    /**
     * 导出巡检线路1列表
     */
    @RequiresPermissions("system:line:export")
    @Log(title = "巡检线路1", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RoutingLine routingLine)
    {
        List<RoutingLine> list = routingLineService.selectRoutingLineList(routingLine);
        ExcelUtil<RoutingLine> util = new ExcelUtil<RoutingLine>(RoutingLine.class);
        return util.exportExcel(list, "巡检线路1数据");
    }

    /**
     * 新增巡检线路1
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存巡检线路1
     */
    @RequiresPermissions("system:line:add")
    @Log(title = "巡检线路1", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RoutingLine routingLine)
    {
        return toAjax(routingLineService.insertRoutingLine(routingLine));
    }

    /**
     * 修改巡检线路1
     */
    @RequiresPermissions("system:line:edit")
    @GetMapping("/edit/{routingLineId}")
    public String edit(@PathVariable("routingLineId") Long routingLineId, ModelMap mmap)
    {
        RoutingLine routingLine = routingLineService.selectRoutingLineByRoutingLineId(routingLineId);
        mmap.put("routingLine", routingLine);
        return prefix + "/edit";
    }

    /**
     * 修改保存巡检线路1
     */
    @RequiresPermissions("system:line:edit")
    @Log(title = "巡检线路1", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RoutingLine routingLine)
    {
        return toAjax(routingLineService.updateRoutingLine(routingLine));
    }

    /**
     * 删除巡检线路1
     */
    @RequiresPermissions("system:line:remove")
    @Log(title = "巡检线路1", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(routingLineService.deleteRoutingLineByRoutingLineIds(ids));
    }
}
